package com.xiaoka.ins.corp.api.aics.common;

import java.text.MessageFormat;
import java.util.Date;
import java.util.List;

import com.xiaoka.ins.corp.api.aics.dto.RequestBill;
import com.xiaoka.ins.corp.api.aics.dto.config.Region;
import com.xiaoka.ins.corp.api.aics.dto.config.StaticConfig;
import com.xiaoka.ins.corp.api.aics.wsclient.AgentData;
import com.xiaoka.ins.corp.api.aics.wsclient.AuthorityData;
import com.xiaoka.ins.corp.api.aics.wsclient.CoverageData;
import com.xiaoka.ins.corp.api.aics.wsclient.DeliveryInfoData;
import com.xiaoka.ins.corp.api.aics.wsclient.RequestCvrg;
import com.xiaoka.ins.corp.api.aics.wsclient.RequestHead;
import com.xiaoka.ins.corp.api.aics.wsclient.RequestPrmCoef;
import com.xiaoka.ins.corp.api.aics.wsclient.SearchVHLQuotationCiCondition;
import com.xiaoka.ins.corp.api.aics.wsclient.bill99pay.ThirdBill99PayRequest;
import com.xiaoka.ins.corp.api.aics.wsclient.bill99pay.ThirdBill99PayRequestBase;
import com.xiaoka.ins.corp.api.aics.wsclient.checkbiz.UnderWriteVehicleInsurancePolicyCiRequest;
import com.xiaoka.ins.corp.api.aics.wsclient.checkbiz.UnderWriteVehicleInsurancePolicyCiServiceResponse;
import com.xiaoka.ins.corp.api.aics.wsclient.checkbiz.UnderwriteVHLPolicyCiCondition;
import com.xiaoka.ins.corp.api.aics.wsclient.genpolicy.ConfirmVHLApplyCondition;
import com.xiaoka.ins.corp.api.aics.wsclient.genpolicy.ConfirmVehicleInsuranceApplyRequest;
import com.xiaoka.ins.corp.api.aics.wsclient.quotebiz.QueryVehicleInsuranceQuotationCiRequest;
import com.xiaoka.ins.corp.api.aics.wsclient.quotebiznew.NewDeptQuotationCiCondition;
import com.xiaoka.ins.corp.api.aics.wsclient.quotebiznew.NewDeptQuotationCiRequest;
import com.xiaoka.ins.corp.api.aics.wsclient.quotetraffic.QueryVehicleInsuranceQuotationSaliRequest;
import com.xiaoka.ins.corp.api.aics.wsclient.quotetraffic.QueryVehicleInsuranceQuotationSaliServiceResponse;
import com.xiaoka.ins.corp.api.aics.wsclient.quotetraffic.SearchVHLQuotationSailCondition;
import com.xiaoka.ins.corp.api.aics.wsclient.vehicletype.QueryVehicleTypesRequest;
import com.xiaoka.ins.corp.api.config.AicsConfig;
import com.xiaoka.ins.corp.api.dto.request.CustomerDto;
import com.xiaoka.ins.corp.api.dto.request.RiskDto;
import com.xiaoka.ins.corp.api.dto.request.VehicleDto;
import com.xiaoka.ins.corp.api.utils.BaseUtils;
import com.xiaoka.ins.corp.api.utils.DateEnum;

/**
 * @author 参数管理
 */
public class ParametersManager {

	public ParametersManager(AicsConfig aicsConfig) {
		this.authorityData = new AuthorityData();
		authorityData.setUserName(aicsConfig.getUserName());
		authorityData.setPassword(aicsConfig.getPassWord());
	}

	/**
	 * 初始化默认参数
	 * 
	 * @param vehicleDto
	 * @param custDto
	 * @param risks
	 * @param bill
	 * @throws Exception
	 */
	public void initRequestBill(RequestBill bill, VehicleDto vehicleDto,
			CustomerDto custDto, List<RiskDto> risks) {
		// 获取区域配置信息
		Region region = StaticConfig.regions.stream()
				.filter(p -> p.getCityId().equals(custDto.getCityId()))
				.findFirst().get();
		if (null == region) {
			throw new NullPointerException("Region Config Not Find");
		}

		bill.setAutoPricesFlag("1");
		bill.setFromCde("00021");

		bill.setRegion(region);
		bill.setCustomerDto(custDto);
		bill.setVehicleDto(vehicleDto);

		bill.setDeptCode(region.getDeptCode());
		bill.setSecondCode(region.getDeptCode().substring(0, 2));
		// 生效时间
		bill.setBeginDate(BaseUtils.dateFormat(custDto.getBegin(),
				"yyyy-MM-dd HH:mm:ss"));
		// 结束时间
		Date end = BaseUtils.addDate(custDto.getBegin(), 1, DateEnum.Year);
		bill.setEndDate(BaseUtils.dateFormat(end, "yyyy-MM-dd 23:59:59"));
		bill.setBirthday(BaseUtils.getFormatBirthday(custDto.getIdNo()));
		bill.setBeginYear(BaseUtils.dateFormat(custDto.getBegin(), "yyyy-MM-dd"));
		bill.setEndYear(BaseUtils.dateFormat(end, "yyyy-MM-dd"));
		String driverSex = BaseUtils.getGenderByID(custDto.getIdNo()) == "1" ? "341007001"
				: "341007002", sex = BaseUtils.getGenderByID(custDto.getIdNo()) == "1" ? "106001"
				: "106002";
		bill.setDriverSex(driverSex);
		bill.setSex(sex);

		bill.setOperatorCode(region.getOperatorCode());
		// 客户类型 0 法人 1 个人（中国籍） 2 个人（非中国籍）
		bill.setCustType("1");
		bill.setSeatCapacity((vehicleDto.getVehicleSeat() - 1));
		// 是否外地车 外地车必输：默认：0（0否，1是）
		bill.setEcdemicVehicleFlag(custDto.getVehicleLicenceCode().startsWith(
				region.getName()) ? "0" : "1");
		// 过户车标记 0 非过户车 1 过户车
		bill.setTransferFlag("0");
		// 过户日期
		bill.setTransferDate("");
		bill.setSpecialDeclare("");
		Date now = new Date();
		bill.setOpreated(BaseUtils.dateFormat(now, "yyyy-MM-dd HH:mm:ss"));
		// 设置首次登记时间
		bill.setFirstRegDate(BaseUtils.dateFormat(custDto.getFirstReg(),
				"yyyy-MM-dd"));
		// 新旧车标志 超过9个月就是旧车待确定 0 新车 1 旧车
		String newVehicleFlag = BaseUtils.addDate(custDto.getFirstReg(), 9,
				DateEnum.Month).compareTo(now) > 0 ? "0" : "1";
		bill.setNewVehicleFlag(newVehicleFlag);
		// 如果发证日期不等于首次登记日期且过户日期还未满一年 则为过户车
		if (BaseUtils.dateFormat(custDto.getTransferDate(), "yyyy-MM-dd") != BaseUtils
				.dateFormat(custDto.getFirstReg(), "yyyy-MM-dd")
				&& BaseUtils.addDate(custDto.getTransferDate(), 1,
						DateEnum.Year).compareTo(now) > 0) {
			bill.setTransferFlag("1");
			bill.setTransferDate(BaseUtils.dateFormat(
					custDto.getTransferDate(), "yyyy-MM-dd"));
			bill.setSpecialDeclare("33908");
		}

		int useAge = BaseUtils.getDifferYear(now, custDto.getFirstReg(),
				DateEnum.Year), vehicleSeat = vehicleDto.getVehicleSeat();
		System.out.println(useAge);
		String useAges = "", trafficUseages = "";
		// 使用年限 根据初登记如期计算: [1,2)年:341100001 [2,3)年:341100002 [3,4)年:341100003
		// [4,5)年:341100004 [5,6)年:341100005 [6,+)年:341100006
		if (useAge > 0 && useAge <= 2) {
			useAges = "341100001";
		} else if (useAge > 2 && useAge <= 3) {
			useAges = "341100002";
		} else if (useAge > 3 && useAge <= 4) {
			useAges = "341100003";
		} else if (useAge > 4 && useAge <= 5) {
			useAges = "341100004";
		} else if (useAge > 5 && useAge <= 6) {
			useAges = "341100005";
		} else {
			useAges = "341100006";
		}
		bill.setUseAge(useAge);
		bill.setUseAges(useAges);
		// 交强险使用年限
		// [324001:1年以内,324002:1至5年,324003:5至8年,324004:8至10年,324005:10年以上]
		if (useAge <= 1) {
			trafficUseages = "324001";
		} else if (useAge > 1 && useAge <= 5) {
			trafficUseages = "324002";
		} else if (useAge > 5 && useAge <= 8) {
			trafficUseages = "324003";
		} else if (useAge > 8 && useAge <= 10) {
			trafficUseages = "324004";
		} else {
			trafficUseages = "324005";
		}
		bill.setTrafficUseages(trafficUseages);

		String taxPoCategory = "";
		// K01 9坐（含）以下且排量1.0升（含）以下的乘用车
		// K02 9坐（含）以下且排量1.0升以上至1.6升（含）的乘用车
		// K03 9坐（含）以下且排量1.6升以上至2.0升（含）的乘用车
		// K04 9坐（含）以下且排量2.0升以上至2.5升（含）的乘用车
		// K05 9坐（含）以下且排量2.5升以上至3.0升（含）的乘用车
		// K06 9坐（含）以下且排量3.0升以上至4.0升（含）的乘用车
		// K07 9坐（含）以下且排量4.0升以上的 乘用车
		// K08 核定载客人数9人以上20人以下中型客车
		// K09 核定载客人数20人（含）以上大型客车，包括电车
		float exhausMeasure = vehicleDto.getExhaustMeasure().floatValue();
		if (exhausMeasure <= 1) {
			taxPoCategory = "K01";
		} else if (exhausMeasure > 1 && exhausMeasure <= 1.6) {
			taxPoCategory = "K02";
		} else if (exhausMeasure > 1.6 && exhausMeasure <= 2) {
			taxPoCategory = "K03";
		} else if (exhausMeasure > 2 && exhausMeasure <= 2.5) {
			taxPoCategory = "K04";
		} else if (exhausMeasure > 2.5 && exhausMeasure <= 3) {
			taxPoCategory = "K05";
		} else if (exhausMeasure > 3 && exhausMeasure <= 4) {
			taxPoCategory = "K06";
		} else {
			taxPoCategory = "K07";
		}
		bill.setTaxPoCategory(taxPoCategory);
		// 337001 六座以下客车 337002 6-10座客车
		if (vehicleSeat > 6 && vehicleSeat < 10) {
			bill.setVehicleCategory("337002");
		} else {
			bill.setVehicleCategory("337001");
		}

		// 其他地区：
		// 燃油 32773001
		// 纯电力 32773002
		// 燃料电池 32773003
		// 插电式混合动力 32773004
		// 其他混合动力 32773005
		String fuelType = "32773001";
		String multiCoverageAdjust = "1";
		// 北京
		if (custDto.getCityId() == "北京") {
			// 能源类型 北京地区：
			// 汽油 32773101
			// 柴油 32773102
			// 电 32773103
			// 混合油 32773104
			// 天然气 32773105
			// 液化石油气 32773106
			// 甲醇 32773107
			// 乙醇 32773108
			// 太阳能 32773109
			// 混合动力 32773110
			// 无 32773111
			// 其他 32773112
			fuelType = "32773101";
			if (risks.size() >= 2) {
				multiCoverageAdjust = "0.9";
			}
		}
		bill.setFuelType(fuelType);
		bill.setMultiCoverageAdjust(multiCoverageAdjust);
		// 缴税日期 新车应该是初登日期当月1月1号至当年12月31号 非新车应该是当年1月1号至当年12月31号
		String taxPaidDate = MessageFormat.format("{0}-01-01到{0}-12-31",
				BaseUtils.dateFormat(now, "yyyy"));
		bill.setTaxPaidDate(taxPaidDate);
	}

	/**
	 * 生成车型查询请求参数
	 * 
	 * @param request
	 * @param brandName
	 */
	public void buildQueryVehicleTypesRequest(QueryVehicleTypesRequest request,
			String brandName) {
		request.setAuthorityData(authorityData);
		request.setSearchKeyword(brandName);
	}

	/**
	 * 生成商业险请求参数
	 * 
	 * @param request
	 * @param bill
	 * @param glassType
	 */
	public void buildQueryVehicleInsuranceQuotationCiRequest(
			QueryVehicleInsuranceQuotationCiRequest request, RequestBill bill,
			String glassType, List<CoverageData> coverages) {

		request.setAuthorityData(authorityData);
		request.setAreaCode(bill.getRegion().getAreaCode());
		// 是否是电销流程标识 0表示走传统流程，1表示走电销流程
		request.setProductSign(bill.PRODUCT_SIGN);

		SearchVHLQuotationCiCondition condition = new SearchVHLQuotationCiCondition();
		condition.setAutoPricesFlag(bill.getAutoPricesFlag());
		condition.setDataSource(bill.DATASOURCE);
		// 商业险0350，交强险0326
		condition.setProductNo(bill.BIZ_PRODUCTNo);
		// 机构编码: 上海网电销业务部 0376
		condition.setDeptCode(bill.getDeptCode());
		condition.setStartDate(bill.getBeginDate());
		condition.setEndDate(bill.getEndDate());
		// 系数类型 月或日费率 340001 按日计算 340002 按月计算
		condition.setRatioType("340001");
		// 短期系数 保险期限1年，默认为 1.000000
		condition.setRatio("1.000000");
		condition.setExchangeRate("1");
		// 保额币种 默认传01
		condition.setAmtCur("01");
		// 保费币种
		condition.setPrmCur("01");
		condition.setSignDate(bill.getOpreated());
		// 续保标志 0 非续保 1 续保 暂时传0 后面要根据接口来查询是否之前投过保
		condition.setRenewalFlag("0");
		// 录入人
		condition.setOperatorCode(bill.getOperatorCode());
		// 车船税标志 0:不交车船税 1:交车船税
		condition.setTaxFlag("0");
		// 投保人姓名
		condition.setAppName(bill.getCustomerDto().getName());
		// 被保险人姓名
		condition.setInsuredName(bill.getCustomerDto().getName());
		// 操作日期
		condition.setOperateDate(bill.getOpreated());
		// 任务类型 电销使用：0:呼入 1呼出
		condition.setTaskType("");
		// 业务模式 0:电销 1:网销 2:网转电
		condition.setBusinessMode("1");
		// 新业务来源 "新业务来源"必须在“业务来源”传“电销”或者“网销”时才传以下值
		// ：191020(常规电销业务);191018(常规网销业务);191019(闭环电销业务);191017(闭环网销业务);191026(电销新业务);191027(网销新业务)
		condition.setBusinessStyle("191027");
		condition.setCmpnyagtCde("");
		condition.setComputerIp("");
		condition.setUsbkey("");
		condition.setPosNo("");
		condition.setAppJqFlag("Y");
		// 险别信息
		condition.getRequestCoverageDatas().addAll(coverages);
		// 行驶证车主
		condition.setOwner(bill.getCustomerDto().getName());
		// 车牌号码
		condition.setCarMark(bill.getCustomerDto().getVehicleLicenceCode());
		// 发动机
		condition.setEngineNo(bill.getCustomerDto().getEngineNo());
		// 车架号
		condition.setRackNo(bill.getCustomerDto().getVehicleFrameNo());
		// 车型名称 车型查询接口中的VEHICLE_NAME字段值
		condition.setVehicleBrand(bill.getVehicleDto().getBrandName());
		// 车型代码
		condition.setVehicleModel(bill.getVehicleDto().getVehicleId());
		// 首次登记日期
		condition.setRegisterDate(bill.getFirstRegDate());
		// 牌号种类 02 小型汽车号牌 03 使馆汽车号牌 06 外籍汽车号牌 07 两、三轮摩托车号牌 13 农用运输车号牌
		condition.setVehicleType("02");
		// 所属性质 338001 个人 338002 机关 338003 企业
		condition.setBelongType("338001");
		// 核定载客数 车型查询接口中VEHICLE_SEAT
		condition.setLimitLoadPerson(bill.getVehicleDto().getVehicleSeat()
				.toString());
		// 排气量
		condition.setExhaustCapacity(bill.getVehicleDto().getExhaustMeasure()
				.toString());
		// 新旧车标志 0 新车,1 旧车
		condition.setNewVehicleFlag(bill.getNewVehicleFlag());
		// 新车购置价 车型查询接口中SZXH_TAXED_PRICE
		condition.setVehiclePrice(bill.getVehicleDto()
				.getPurchasePriceIncludeTax());
		// 车辆类型
		condition.setVehicleCategory(bill.getVehicleCategory());
		// 使用年限 根据初登记如期计算
		condition.setUseAges(bill.getUseAges());
		condition.setTonnage("0");
		condition.setPower(bill.getVehicleDto().getVehiclePower());
		condition.setSeatCapacity(bill.getVehicleDto().getVehicleSeat()
				.toString());
		condition.setCitizenRelocatedDate("");
		condition.setEcdemicVehicleFlag(bill.getEcdemicVehicleFlag());
		condition.setGroupPurchaseContactNo("");
		condition.setChangeOwnerFlag(bill.getTransferFlag());
		condition.setRegistrationTransferedDate(bill.getTransferDate());
		condition.setRenewalPolicyNo("");
		condition.setCertDate(bill.getFirstRegDate());
		condition.setQuerySequenceNo("");
		condition.setReinsFlag("0");
		condition.setDriverPeriodAdjust("");
		condition.setDriverGenderAdjust("");
		condition.setDriverAgeAdjust("");
		condition.setRunAreaAdjust("341103001");
		condition.setAverageRunMileage("341104002");
		condition.setAppYear("341020001");
		condition.setTrafficCommitmentRecord("");
		condition.setIndemnityRecord("1.0");
		condition.setGlassType(glassType);
		condition.setPoCategory("K33");
		// 使用性质 非营业：336001
		condition.setUserType("336001");
		// 车损免赔额
		condition.setNoclaimAmountCode("0");
		condition.setAnswer("");
		condition.setDefineWay("");
		condition.setVehicleQuality(bill.getVehicleDto().getVehicleQuality());
		// 二级机构
		condition.setSecondaryOrganization(bill.getSecondCode());
		condition.setSnapFlag("0");
		// 费率调整系数上调
		condition.setRateUpAdjust("1");
		condition.setVehicleNumAdjust("");
		// 平均年行驶里程系数范围 平均行驶里程为非341104003时，这个字段值为1，且只读；否则此字段在[1.1, 1.3]之间填写
		condition.setAverageMileageAdjust("1");
		// 多险别投保优惠 默认为1.北京地区投了030118险，且商业险投了两种及以上的险，这里为0.9
		condition.setMultiCoverageAdjust(bill.getMultiCoverageAdjust());
		// 车损险车型系数 默认为1.可选范围依机构不同而不同
		condition.setVehicleDamageAdjust("1");
		// 经验/预期赔付率 默认为1
		condition.setExperienceAdjust("1");
		// 车队管理
		condition.setMotorcadeManageAdjust("1");
		// 安全驾驶系数
		condition.setSafeAdjust("1");
		// 车损免赔系数 默认传1
		condition.setNoclaimAmountAdjust("1");
		// 车龄
		condition.setVehicleAge(bill.getUseAge().toString());
		// 无赔款优待系数
		condition.setNonclaimAdjust("0");
		// 客户忠诚度系数
		condition.setLoyaltyAdjust("1");
		// 特殊风险系数
		condition.setSpecialRiskAdjust("1");
		condition.setVehicleLossAdjustIm("1");
		condition.setLiabilityAdjustIm("1");
		condition.setAppendAdjustIm("1");
		condition.setRobAdjustIm("1");
		condition.setVehicleStaffAdjustIm("1");
		condition.setBaseNoclaimAdjustIm("1");
		condition.setAppendNoclaimAdjustIm("1");
		condition.setVehicleTypeAdjust("341021001");
		condition.setDiscountType("336001");
		condition.setExperience("");
		condition.setAgreedRoute("");
		condition.setDriverAdjustValue("1");
		condition.setCompadjustReason("");
		condition.setComppeccancyCoef("1");
		// 指定驾驶员 341101001：指定驾驶人 341101002：未指定驾驶人
		condition.setDriverAdjust("341101002");
		condition.setAgtagrNo("");
		condition.setAppContact(bill.getCustomerDto().getName());
		condition.setCustomerName("");
		condition.setDrvOwnerBirthday("");
		condition.setDrvOwnerNme("");
		condition.setDrvOwnerSex("");
		// 合作业务来源
		condition.setFromCde(bill.getFromCde());
		condition.setSalesmanNo(bill.getOperatorCode());
		condition.setSource("echannel");
		condition.setUseType("336001");
		// 业务来源
		condition.setBusinessType("19008");
		condition.setOperateDate(bill.getOpreated());
		condition.setSignDate(bill.getOpreated());
		// 核心业务 0: GB,1:KB自营, 2: KB下放默认传0
		condition.setKernelFlag("0");

		AgentData agentData = new AgentData();
		agentData.setAgentCode("");
		agentData.setConferCode("");
		agentData.setAgentType("");
		agentData.setAgentCategory("");
		agentData.setCommissionProprortion("0");
		agentData.setAgentProfId("");
		agentData.setAgentStaffNme("");
		agentData.setAgentNme("");
		agentData.setAgentSaleNme("");
		agentData.setAgentCategoryNme("");
		// 客户性质 客户性质 193001 股东 193002 非股东
		agentData.setCustNature("193002");
		agentData.setCusLvl("");
		agentData.setSubCoNo("");
		agentData.setQlftNo("");
		// 合作业务来源
		agentData.setFromCde(bill.getFromCde());
		agentData.setEnterpriseCde("");
		agentData.setEnterpriseNme("");
		agentData.setEnterpriseLvl("");
		agentData.setEnterpriseClass("");
		agentData.setSupportServiceProvider("");
		agentData.setSupportServicePacket("");
		agentData.setAgentStockMrk("");
		agentData.setAgentBankType("");
		agentData.setDutyCde("");
		agentData.setDutyCnm("");
		agentData.setAgentStockType("");
		agentData.setExtProp("");
		agentData.setExtPrm("");
		agentData.setPreventRate("");
		agentData.setTrainRate("");
		condition.setAgentData(agentData);
		request.setCondition(condition);
	}

	/**
	 * 费改商业险请求
	 * 
	 * @param request
	 * @param bill
	 * @param coverages
	 */
	public void buildNewDeptQuotationCiRequest(
			NewDeptQuotationCiRequest request, RequestBill bill,
			List<RequestCvrg> coverages) {

		request.setAuthorityData(authorityData);
		request.setAreaCode(bill.getRegion().getAreaCode());
		NewDeptQuotationCiCondition condition = new NewDeptQuotationCiCondition();
		// 保额币种 01人民币
		condition.setAmtCur("01");
		// 集中平台转保业务，第二次请求必传
		condition.setAnswer("");
		// 是否投保交强 若联合投保则该字段必传Y:是 N:否
		condition.setAppJqFlag("Y");
		// 是否走自动报价 1表示走自动报价，0和空都是不走自动报价
		condition.setAutoPricesFlag("1");
		// 所属性质 338001 个人 338002 机关 338003 企业
		condition.setBelongType("338001");
		// 业务模式 1:网销
		condition.setBusinessMode("1");
		// 新业务来源 必须在“业务来源”传“电销”或者“网销”时才传以下值
		// ：191020(常规电销业务);191018(常规网销业务);191019(闭环电销业务);191017(闭环网销业务);191026(电销新业务);191027(网销新业务)
		condition.setBusinessStyle("191018");
		// 业务来源
		condition.setBusinessType("19008");
		// 业务合作来源
		condition.setCAgrSlsBsns(bill.getFromCde());
		// 指定查询地区查询无赔系数 N
		condition.setCAppointAreaCode("");
		// 车牌号码
		condition.setCarMark(bill.getCustomerDto().getVehicleLicenceCode());
		// 业务类型 0：新保 1：续保 2：转保
		condition.setCBusType("0");
		// 是否租赁车 N 1：是
		condition.setCDevice8Mrk("0");
		// 过户标志
		condition.setChangeOwnerFlag(bill.getTransferFlag());
		// 是否及时生效 1：即时生效 0：非即时生效
		condition.setCImmeffMrk("1");
		// 验车情况 305005001：未验 305005002：已验车 305005003：免验车 305005004：需验车
		condition.setCInspectionCde("");
		// 验车人 当验车情况是已验车必传
		condition.setCInspectorNme("");
		// 验车记录 当验车情况是已验车必传
		condition.setCInspectRec("");
		// 验车时间 当验车情况是已验车必传
		condition.setCInspectTm("");
		// 转籍时间年月 外地车必输YYYY-MM-DD
		condition.setCitizenRelocatedDate("");
		// 代理人/经纪人 业务来源为代理业务、经济业务时该项必传
		condition.setCmpnyagtCde("");
		// 车牌颜色
		condition.setCPlateColor("");
		// 行业车型编码
		condition.setCPlateModelCde("");
		// 承租人
		condition.setCResvTxt11("");
		// 车损确定方式
		condition.setDefineWay("");
		// 机构编码
		condition.setDeptCode(bill.getDeptCode());
		// 是否外地车
		condition.setEcdemicVehicleFlag(bill.getEcdemicVehicleFlag());
		// 保险止期
		condition.setEndDate(bill.getEndDate());
		// 发动机号
		condition.setEngineNo(bill.getCustomerDto().getEngineNo());
		// 汇率
		condition.setExchangeRate("1");
		// 排气量
		condition.setExhaustCapacity(bill.getVehicleDto().getExhaustMeasure()
				+ "");
		// 玻璃类型
		condition.setGlassType(bill.getCustomerDto().getVehicleFrameNo()
				.toUpperCase().startsWith("L") ? "303011001" : "303011002");
		// 团车合同号
		condition.setGroupPurchaseContactNo("");
		// 核定载客数
		condition
				.setLimitLoadPerson(bill.getVehicleDto().getVehicleSeat() + "");
		// 折旧价
		condition.setNActualValue(BaseUtils.toDepreciation(BaseUtils
				.toDecimal(bill.getVehicleDto().getPurchasePriceIncludeTax()),
				bill.getCustomerDto().getFirstReg(), bill.getCustomerDto()
						.getBegin())
				+ "");
		// 新旧车标志
		condition.setNewVehicleFlag(bill.getNewVehicleFlag());
		// 月折旧率
		condition.setCitizenRelocatedDate("6‰");
		// 协商价
		condition.setNNewPurchaseValue("");
		// 公告型号
		condition.setNoticeType("");
		// 操作人代码
		condition.setOperatorCode(bill.getOperatorCode());
		// 行驶证车主
		condition.setOwner(bill.getCustomerDto().getName());
		// 行驶证车辆类型
		condition.setPoCategory("K33");
		// 功率
		condition.setPower(bill.getVehicleDto().getVehiclePower());
		// 参见代码 目前只支持01人民币
		condition.setPrmCur("01");
		// 产品编码
		condition.setProductNo(bill.TRF_PRODUCTNo);
		// 查询码
		condition.setQuerySequenceNo("");
		// 车架号
		condition.setRackNo(bill.getCustomerDto().getVehicleFrameNo());
		// 短期系数
		condition.setRatio("1");
		// 短期费率类型 340001 按日计算（D） 340002 按月计算（M）
		condition.setRatioType("340002");
		// 初次登记日期
		condition.setRegisterDate(bill.getFirstRegDate());
		// 转移登记日期 过户车必输 YYYY-MM-DD
		condition.setRegistrationTransferedDate(bill.getTransferDate());
		// 续保单号（往年（续/转）保单号）
		condition.setRenewalPolicyNo("");

		RequestHead requestHead = new RequestHead();
		requestHead.setCDataSource(bill.DATASOURCE);
		// 保费计算：100002 ；申请核保：100004
		requestHead.setCRequestType("100002");
		condition.setRequestHead(requestHead);
		RequestPrmCoef requestPrmCoef = new RequestPrmCoef();
		// 交强违法浮动原因（平台代码）
		requestPrmCoef.setCClaimAdjustReason("");
		// 交强违法浮动系数
		requestPrmCoef.setCTraSafFloRate("");
		// 交强赔款记录系数
		requestPrmCoef.setNAgoClaProFloat("");
		// 交强出险记录（交强无赔系数原因，平台代码）
		requestPrmCoef.setNAgoClmRecQuick("");
		// 自主核保系数
		requestPrmCoef.setNAutonomyAdjust("1");
		// 自主渠道系数
		requestPrmCoef.setNChannelAdjust("1");
		// 期望折扣标志
		requestPrmCoef.setCResvTxt1("0");
		// 期望折扣
		requestPrmCoef.setNResvNum4("");
		condition.setRequestPrmCoef(requestPrmCoef);
		// 险别
		condition.getRequestCvrgList().addAll(coverages);
		condition.setSalesmanNo(bill.getOperatorCode());
		condition.setSeatCapacity(bill.getVehicleDto().getVehicleSeat() + "");
		condition.setSignDate(bill.getOpreated());
		condition.setSnapFlag("0");
		condition.setStartDate(bill.getBeginDate());
		condition.setTaskType("0");
		condition.setTonnage("0");
		condition.setUseAges(bill.getUseAges());
		condition.setUseType("336001");
		condition.setVehicleBrand(bill.getVehicleDto().getBrandName());
		condition.setVehicleCategory(bill.getVehicleCategory());
		condition.setVehicleModel(bill.getVehicleDto().getVehicleId());
		condition.setVehiclePrice(bill.getVehicleDto()
				.getPurchasePriceIncludeTax());
		condition.setVehicleQuality(bill.getVehicleDto().getVehicleQuality());
		condition.setVehicleType("02");
		request.setCondition(condition);
	}

	public void buidUnderWriteVehicleInsurancePolicyCiRequest(
			UnderWriteVehicleInsurancePolicyCiRequest request, RequestBill bill) {

		request.setAuthorityData(authorityData);
		// 配送信息DTO
		DeliveryInfoData deliveryData = new DeliveryInfoData();
		// 收货人姓名
		deliveryData.setName(bill.getDeliveryDto().getReceiveName());
		// 收货人手机
		deliveryData.setCellphone(bill.getDeliveryDto().getReceiveMobile());
		// 发票抬头
		deliveryData.setReceiptHead(bill.getDeliveryDto().getReceiptHead());
		// 地址
		deliveryData.setAddress(bill.getDeliveryDto().getReceiveAddress());
		// 0家庭住址，1单位住址
		deliveryData.setAddressFlag(bill.getDeliveryDto()
				.getReceiveAddressFlag());
		// 备注
		deliveryData.setRemark(bill.getDeliveryDto().getReceiveRemark());
		// 配送类别 0-配送；1-邮寄
		deliveryData.setDeliveryType("0");
		// 非车配送详细 发票和纸质保单，0-纸质保单，1-发票，2-纸质保单和发票
		deliveryData.setDeliveryDetail("2");
		// 产品种类 0车险 1非车
		deliveryData.setProductSort("0");
		// 邮编
		deliveryData.setZip("");
		// 电话区号
		deliveryData.setTelArea("");
		// 电话
		deliveryData.setTelephone("");
		// 称谓 先生 女士
		deliveryData.setTitle("");
		request.setDeliveryInfo(deliveryData);
		// 是否是电销流程标识 0表示走传统流程，1表示走电销流程
		request.setProductSign(bill.PRODUCT_SIGN);
		UnderwriteVHLPolicyCiCondition condition = new UnderwriteVHLPolicyCiCondition();
		// 数据来源
		condition.setDataSource(bill.DATASOURCE);
		// 核保标志 0按系统默认 1自动核保 2不自动核保
		condition.setAutoCheck("0");
		// 操作类型 I：新增 U：修改(选择此项时需要传待修改的投保单号) 申请核保传I 重新申请核保传(即修改投保单)U
		condition.setOperTyp("I");
		// 单证类型 A：投保 P：保单 B：批单申请 E：批单
		condition.setDocTyp("A");
		// 商业险
		condition.setProductNo(bill.BIZ_PRODUCTNo);
		// 机构编码
		condition.setDeptCode(bill.getDeptCode());

		request.setCondition(condition);

		// //保险起期
		// startDate = bill.begindate,
		// //保险止期
		// endDate = bill.enddate,
		// //系数类型 月或日费率 340001 按日计算 340002 按月计算
		// ratioType = "340001",
		// //短期系数 保险期限1年，默认为 1.000000
		// ratio = "1.000000",
		// //汇率
		// exchangeRate = "1",
		// //保额合计
		// amount = cacheData.amount,
		// //保费合计
		// premium = cacheData.premium,
		// //传商业险试算返回的VEHICLE_ADJUST中的TOTAL_DISCOUNT
		// totalDiscount = cacheData.totalDiscount,
		// //保额币种 默认传01
		// amtCur = "01",
		// //保费币种
		// prmCur = "01",
		// //续保标志 0 非续保 1 续保 暂时传0 后面要根据接口来查询是否之前投过保
		// renewalFlag = "0",
		// //车船税标志
		// taxFlag = "0",
		// //业务来源
		// 电销：19009，网销：19008。传“电销”时“新业务来源”对应值（191020，191019，191026）；“网销”时“新业务来源”对应值（191018，191017，191027）
		// businessType = "19008",
		// //签单日期
		// signDate = DateTime.Now.ToString("yyyy-MM-dd"),
		// //核心业务 0: GB,1:KB自营, 2: KB下放默认传0
		// kernelFlag = "0",
		// //业务员代码11927000E
		// salesmanNo = areaConfig.OperatorCode,
		// //投保人姓名
		// appName = bill.holdername,
		// //投保人联系人
		// appContact = bill.holdername,
		// //投保人联系人电话
		// appTel = bill.holderphone,
		// //投保人地址
		// appAddress = "",
		// //投保人邮编
		// appZip = bill.holderzip,
		// //投保人证件号码
		// appCertiCode = bill.holderidno,
		// //被保险人姓名
		// insuredName = bill.holdername,
		// insuredTel = bill.holderphone,
		// insuredAddress = "",
		// insuredZip = bill.holderzip,
		// insuredCertiCode = bill.holderidno,
		// //受益人名称 按揭车时该项必传
		// benefitName = bill.holdername,
		// //受益人证件号
		// benefitCertiCode = bill.holderidno,
		// //客户名称
		// customerName = bill.holdername,
		// //男：106001，女：106002
		// sex = bill.sex,
		// //行业
		// industury = "000",
		// //涉农类型
		// agriType = "0",
		// //风险等级 默认传空
		// riskLevel = "",
		// //争议解决方式
		// debateSolve = "007001",
		// remark = "无",
		// //录入人 同“业务员代码”
		// operatorCode = bill.operatorcode,
		// //录单日期 同“签单日期”
		// operatorDate = bill.opreated,
		// //保单生成 默认传 0
		// policyGeneratedType = "0",
		// //打印方式 默认传 0
		// printType = "0",
		// //手续费比例
		// commissionPercentage = "0",
		// //缴费方式 缴费方式 002001（划卡）、002011 （现金）、002017（快钱）002014 (第三方支付)
		// 002018:快钱在线交易
		// paymode = "002018",
		// //保险天数
		// insrncBetweendays = "",
		// //操作日期 同“签单日期”
		// operateDate = bill.opreated,
		// //任务类型 电销使用：0:呼入 1呼出
		// taskType = "0",
		// //业务模式 0:电销 1:网销 2:网转电
		// businessMode = "1",
		// //新业务来源 "新业务来源"必须在“业务来源”传“电销”或者“网销”时才传以下值
		// ：191020(常规电销业务);191018(常规网销业务);191019(闭环电销业务);191017(闭环网销业务);191026(电销新业务);191027(网销新业务)
		// businessStyle = "191018",
		// //订单号 默认传空
		// orderCode = "",
		// //代理人 业务类型为代理业务、经济业务时必传
		// cmpnyageCde = "",
		// //代理协议号 业务类型为代理业务时必传
		// agtagrNo = "",
		// //险别信息
		// requestCoverageDatas = udci_coverageArray,
		// //查询码 传商业险试算返回的查询码
		// querySequenceNo = cacheData.querySequenceNo,
		// //行驶证车主
		// owner = custDTO.name,
		// //车牌号码
		// carMark = custDTO.vehicleLicenceCode,
		// //发动机
		// engineNo = custDTO.engineNo,
		// //车架号
		// rackNo = custDTO.vehicleFrameNo,
		// //车型名称
		// vehicleBrand = vehicleDTO.brandName,
		// //车型代码
		// vehicleModel = guidVehicle.refCode1,
		// //初次登记日期
		// registerDate = bill.firstreg,
		// //牌号种类 02 小型汽车号牌 03 使馆汽车号牌 06 外籍汽车号牌 07 两、三轮摩托车号牌 13 农用运输车号牌
		// vehicleType = "02",
		// //所属性质
		// belongType = "338001",
		// //核定载客数
		// limitLoadPerson = guidVehicle.limitloadperson.ToString(),
		// //排气量
		// exhaustCapacity = guidVehicle.exhaust,
		// //新旧车标志 0 新车,1 旧车
		// newVehicleFlag = bill.newvehicleFlag,
		// //新车购置价
		// vehiclePrice = guidVehicle.vehiclePrice.ToString(),
		// //车辆类型 337001 六座以下客车337002 6-10座客车
		// vehicleCategory = bill.vehicleCategory,
		// //使用年限 根据初登记如期计算:
		// useAges = bill.useages,
		// //吨位数
		// tonnage = guidVehicle.tonnage,
		// //功率
		// power = vehicleDTO.vehiclePower.ToString(),
		// //座位数
		// seatCapacity = bill.seatCapacity,
		// userType = bill.custtype,
		// //转籍时间年月
		// citizenRelocatedDate = "",
		// //是否外地车 外地车必输：默认：0（0否，1是）
		// ecdemicVehicleFlag = bill.ecdemicVehicleFlag,
		// //团车合同号
		// groupPurchaseContactNo = "",
		// //过户车标志~
		// changeOwnerFlag = bill.transferFlag,
		// //转移登记日期
		// registrationTransferedDate = bill.transferDate,
		// //往年（续/转）保单号
		// renewalPolicyNo = "",
		// //车损免赔额 NOCLAIM_AMOUNT_CODE ?? 没找到
		// //验车情况
		// checkCode = "305005003",
		// //投保类型 进口：1，其他：0
		// appType = "0",
		// //玻璃类型 国产:303011001 进口:303011002
		// glassType = "303011001",
		// //投保交强 0：不投保交强险 1：投保交强险
		// inteFalg = "0",
		// //车损确定方式 足额投保传，341018001：新车购置价 非足额传，341018002：新车购置价扣减折旧
		// defineWay = "341018001",
		// //原车牌号 可以为空
		// oldCarMark = "",
		// //发证日期
		// certDate = bill.firstreg,
		// //平台车型代码
		// platformVehicleModel = vehicleDTO.vehicleId,
		// //整备质量 暂江苏要求必传
		// vehicleQuality = vehicleDTO.vehicleQuality,
		// //指定驾驶员 传商业险试算返回报文中对应的值
		// driverAdjust = "341101002",
		// //驾驶人年龄
		// driverAgeAdjust = "",
		// //驾驶人性别
		// driverGenderAdjust = "",
		// //驾驶人驾龄
		// driverPeriodAdjust = "",
		// //行驶区域
		// runAreaAdjust = "",
		// //平均年行驶里程（公里）
		// averageRunMileage = "",
		// //投保年度
		// appYear = "341020001",
		// //交通违法记录
		// trafficCommitmentRecord = "",
		// //以往保险年度索赔记录
		// indemnityRecord = "",
		// //二级机构 传机构的前两位，如上海网电销业务部0376就传03
		// secondaryOrganization = bill.secondcode,
		// //承保数量
		// vehicleNumAdjust = "",
		// //费率调整系数上调
		// rateUpAdjust = "1",
		// //平均年行驶里程系数范围 平均行驶里程为非341104003时，这个字段值为1，且只读；否则此字段在[1.1, 1.3]之间填写
		// averageMileageAdjust = "1",
		// //多险别投保优惠 默认为1.北京地区投了030118险，且商业险投了两种及以上的险，这里为0.9
		// multiCoverageAdjust = bill.multiCoverageAdjust,
		// //车损险车型系数 默认为1.可选范围依机构不同而不同
		// vehicleDamageAdjust = "1",
		// //行驶证车辆类型 K33 轿车
		// poCategory = "K33",
		// //使用性质 非营业：336001
		// useType = "336001",
		// //车损免赔额 ? 341003001: 0元 341003003: 300元 341003004: 500元 341003006:
		// 1000元 341003008: 2000元
		// noclaimAmountCode = "0",
		// //经验/预期赔付率 默认为1.
		// experienceAdjust = "1",
		// absoluteFranchise = "",
		// accidentDownwardRate = "",
		// accidentFloatRateLastYear = "",
		// accidentRateResult = "",
		// accidentTimeLastYear = "",
		// age = "",
		// agencyNme = "",
		// agencyProfId = "",
		// agreedRoute = "",
		// appendAdjustIm = "",
		// appendNoclaimAdjustIm = "",
		// appNo = "",
		// appRecord = "",
		// appSail = "",
		// appTime = "",
		// arbitrationDept = "",
		// baseNoclaimAdjustIm = "",
		// carColor = "",
		// coefficientRate = "",
		// company = "",
		// computerIp = "",
		// coveragePercentage = "",
		// depreciationYear = "",
		// discountType = "",
		// drunkDrivingFormula = "",
		// drunkOffensesRate = "",
		// drvOwnerBirthday = "",
		// drvOwnerNme = "",
		// drvOwnerSex = "",
		// email = "",
		// //合作业务来源
		// fromCde = "00021",
		// guardCode = "",
		// inqId = "",
		// liabilityAdjustIm = "",
		// licenseColor = "",
		// minorOffensesLastYear = "",
		// minorOffensesRateLastYear = "",
		// mustPolicyNo = "",
		// nonclaimAdjust = "0",
		// offensesDownwardRate = "",
		// offensesRateResult = "",
		// olympicsReduceCoefficient = "",
		// //otherData = "",
		// park = "",
		// platformVehicleName = "",
		// policyAppNoCi = "",
		// policyAppNoSail = "",
		// posNo = "",
		// reachArea = "",
		// reinsuranceFlag = "",
		// relatedOffensesRate = "",
		// renewalNo = "",
		// //requestDriverDatas = "",
		// robAdjustIm = "1",
		// seriousOffensesLastYear = "",
		// snapFlag = "0",
		// source = "echannel",
		// specialAppoint = "",
		// //如果为过户车辆，则传33908
		// specialDeclareReason = bill.specialDeclare,
		// totalAdjust = "",
		// undrmsgData = new udci.undrmsgData()
		// {
		// //目标机构
		// descDptCde = bill.deptcode,
		// //紧急程度 005001 普通 005002 急 005003 加急 005004 紧急 005005 特急
		// emergency = "005001",
		// //
		// rptDesc = ""
		// },
		// usbkey = "",
		// vehiclEAge = "",
		// vehicleLossAdjustIm = "1",
		// vehicleStaffAdjustIm = "1",
		// vehicleTypeAdjust = "341021001",
		// vhlAdjustTotalDiscount = cacheData.totalDiscount,
		// vhlAdjustVehicleType = "",
		// vhlAppName = "",
		// vhlPriceRate = "",
		// //车队管理
		// motorcadeManageAdjust = "1",
		// //安全驾驶系数
		// safeAdjust = "1",
		// //车损免赔系数 无赔款优待系数 默认为1.可选范围依机构不同而不同
		// noclaimAmountAdjust = "1",
		// //客户忠诚度系数
		// loyaltyAdjust = "1",
		// //特殊风险系数
		// specialRiskAdjust = "1",
		// //车龄 根据投保起期和初等日期来计算
		// vehicleAge = bill.useage.ToString(),
		// //经验/预期赔付率
		// experience = "",
		// //指定驾驶员调整系数 计算返回，暂时江苏平台使用.默认值1.
		// driverAdjustValue = "1",
		// //渠道信息
		// agentData = new udci.agentData()
		// {
		// //commissionProprortion同Base下“手续费比例”
		// commissionProprortion = "",
		// agentNme = "",
		// //客户性质 客户性质 193001 股东 193002 非股东
		// custNature = "193002",
		// //协议序号 代理经纪业务必传
		// subCoNo = ""
		// },
		// //客户信息
		// customer = new udci.customer()
		// {
		// //投保人姓名
		// appName = bill.holdername,
		// //投保人地址
		// appAddress = "",
		// //投保人客户分类
		// appCustType = bill.custtype,
		// appCertiType = bill.holderidtype,
		// appCertiCode = bill.holderidno,
		// appTel = bill.holderphone,
		// insuredAge = bill.holderage,
		// appAge = bill.holderage,
		// appClntQq = "",
		// appEmail = "",
		// appLegalCertificateType = "",
		// appmobileTel = bill.holdermobile,
		// appSchoolName = "",
		// appSex = bill.sex,
		// appZip = bill.holderzip,
		// benefitAge = "",
		// benefitLegalCertificateType = "",
		// benefitName = "",
		// benefitSchoolName = "",
		// benefitSex = "",
		// insuredName = bill.holdername,
		// insuredClntQq = "",
		// insuredEmail = "",
		// insuredLegalCertificateType = "",
		// insuredmobileTel = bill.holdermobile,
		// insuredSchoolName = "",
		// insuredSex = bill.sex,
		// insuredZip = bill.holderzip,
		// insuredAddress = "",
		// //被保险人客户分类
		// insuredCustType = bill.custtype,
		// insuredCertiType = bill.holderidtype,
		// insuredCertiCode = bill.holderidno,
		// insuredTel = bill.holderphone,
		// benefitCustType = "",
		// benefitCertiType = "",
		// benefitCertiCode = ""
	}

	/**
	 * 生成交强险请求参数
	 * 
	 * @param request
	 * @param bill
	 * @param coverages
	 */
	public void buildQueryVehicleInsuranceQuotationSaliRequest(
			QueryVehicleInsuranceQuotationSaliRequest request,
			RequestBill bill, List<CoverageData> coverages) {

		request.setAuthorityData(authorityData);
		request.setAreaCode(bill.getRegion().getAreaCode());
		// 是否是电销流程标识 0表示走传统流程，1表示走电销流程
		request.setProductSign(bill.PRODUCT_SIGN);
		SearchVHLQuotationSailCondition condition = new SearchVHLQuotationSailCondition();
		condition.setDataSource(bill.DATASOURCE);
		// //商业险0350，交强险0326
		condition.setProductNo(bill.TRF_PRODUCTNo);
		// 机构编码: 上海网电销业务部
		condition.setDeptCode(bill.getDeptCode());
		condition.setStartDate(bill.getBeginDate());
		condition.setEndDate(bill.getEndDate());
		// 系数类型 月或日费率 340001 按日计算 340002 按月计算
		condition.setRatioType("340001");
		// 短期系数 保险期限1年，默认为 1.000000
		condition.setRatio("1.000000");
		condition.setExchangeRate("1");
		// 保额币种 默认传01
		condition.setAmtCur("01");
		// 保费币种
		condition.setPrmCur("01");
		condition.setSignDate(bill.getOpreated());
		// 续保标志 0 非续保 1 续保 暂时传0 后面要根据接口来查询是否之前投过保
		condition.setRenewalFlag("0");
		// 录入人
		condition.setOperatorCode(bill.getOperatorCode());
		// 车船税标志 0:不交车船税 1:交车船税
		condition.setTaxFlag("1");
		// 投保人姓名
		condition.setAppName(bill.getCustomerDto().getName());
		// 被保险人姓名
		condition.setInsuredName(bill.getCustomerDto().getName());
		// 操作日期
		condition.setOperateDate(bill.getOpreated());
		// 任务类型 电销使用：0:呼入 1呼出
		condition.setTaskType("");
		// 业务模式 0:电销 1:网销 2:网转电
		condition.setBusinessMode("1");
		// 新业务来源 "新业务来源"必须在“业务来源”传“电销”或者“网销”时才传以下值
		// ：191020(常规电销业务);191018(常规网销业务);191019(闭环电销业务);191017(闭环网销业务);191026(电销新业务);191027(网销新业务)
		condition.setBusinessStyle("191027");
		condition.setCmpnyagtCde("");
		condition.setComputerIp("");
		condition.setUsbkey("");
		condition.setPosNo("");
		// 行驶证车主
		condition.setOwner(bill.getCustomerDto().getName());
		// 车牌号码
		condition.setCarMark(bill.getCustomerDto().getVehicleLicenceCode());
		// 发动机
		condition.setEngineNo(bill.getCustomerDto().getEngineNo());
		// 车架号
		condition.setRackNo(bill.getCustomerDto().getVehicleFrameNo());
		// 车型名称 车型查询接口中的VEHICLE_NAME字段值
		condition.setVehicleBrand(bill.getVehicleDto().getBrandName());
		// 车型代码
		condition.setVehicleModel(bill.getVehicleDto().getVehicleId());
		// 首次登记日期
		condition.setRegisterDate(bill.getFirstRegDate());
		// 牌号种类 02 小型汽车号牌 03 使馆汽车号牌 06 外籍汽车号牌 07 两、三轮摩托车号牌 13 农用运输车号牌
		condition.setVehicleType("02");
		// 所属性质 338001 个人 338002 机关 338003 企业
		condition.setBelongType("338001");
		// 核定载客数 车型查询接口中VEHICLE_SEAT
		condition.setLimitLoadPerson(bill.getVehicleDto().getVehicleSeat()
				.toString());
		// 排气量
		condition.setExhaustCapacity(bill.getVehicleDto().getExhaustMeasure()
				.toString());
		// 新旧车标志 0 新车,1 旧车
		condition.setNewVehicleFlag(bill.getNewVehicleFlag());
		// 新车购置价 车型查询接口中SZXH_TAXED_PRICE
		condition.setVehiclePrice(bill.getVehicleDto()
				.getPurchasePriceIncludeTax());
		// 车辆类型
		condition.setVehicleCategory(bill.getVehicleCategory());
		// 使用年限 根据初登记如期计算
		condition.setUseAges(bill.getTrafficUseages());
		condition.setTonnage("0");
		condition.setSpecialDeclareReason(bill.getSpecialDeclare());
		condition.setEcdemicVehicleFlag(bill.getEcdemicVehicleFlag());
		condition.setPoCategory("K33");
		// 使用性质 非营业：336001
		condition.setUseType("336001");
		// 车损免赔额
		condition.setNoclaimAmountCode("0");
		condition.setVehicleQuality(bill.getVehicleDto().getVehicleQuality());
		// 二级机构
		condition.setSecondaryOrganization(bill.getSecondCode());
		condition.setFuelType(bill.getFuelType());
		// 是否按揭车
		condition.setSnapFlag("0");
		// //购车发票日期 上海平台不允许为空
		condition.setCertificateDate(bill.getFirstRegDate());
		// //收费方式 349002001 正常纳税 349002002 已经完税 349002003 免税 349002004 减免税
		// 349002005 拖欠交税 349002006 新车缓税 349002007 纳税并补税
		condition.setTaxCurrentType("349002001");
		condition.setTaxPayerName(bill.getCustomerDto().getName());
		condition.setTaxBeginDateCurrentYear(bill.getBeginYear());
		condition.setTaxEndDateCurrentYear(bill.getEndYear());
		condition.setVehecleTypeDetail("3490010013");
		// 纳税人识别号 被保险人证件号
		condition.setTaxpayerNo(bill.getCustomerDto().getIdNo());
		// 缴税日期
		condition.setTaxPaidDate(bill.getTaxPaidDate());
		condition.setTaxpayerAddress("0306");
		// 车辆分类 349001001 客车 349001002 货车 349001003 摩托车 349001004 免税车 349001005
		// 减免税车
		condition.setTaxVehicleType("349001001");
		// 纳税人类别 338001 个人 338002 机关 338003 企业
		condition.setTaxpayerType("338001");
		// 纳税人国籍
		condition.setConruty("156");
		// 纳税人电话
		condition.setTel(bill.getCustomerDto().getMobile());
		// 车牌号
		condition.setVehicleNo(bill.getCustomerDto().getVehicleLicenceCode());
		condition.setAddress("");
		condition.setAgtagrNo("");
		condition.setAnnualTaxamt("");
		condition.setAnswer("");
		condition.setAppContact(bill.getCustomerDto().getName());
		condition.setAppName(bill.getCustomerDto().getName());
		condition.setCalcFlag("");
		condition.setCalculatedType("349003001");
		condition.setCalculatedTypeLastYear("");
		condition.setCertDate(bill.getFirstRegDate());
		condition.setChangeOwnerFlag(bill.getTransferFlag());
		condition.setRegistrationTransferedDate(bill.getTransferDate());
		condition.setCitizenRelocatedDate("");
		condition.setCmpnyagtCde("");
		condition.setComputerIp("");
		condition.setCurrentTax("");
		condition.setCustomerName("");
		condition.setDeclareDate("");
		condition.setDecStatus("");
		condition.setDepartment("");
		condition.setDrinkDrivingDealTime("");
		condition.setDrinkDrivingNonDealTime("");
		condition.setDrinkDrivingTime("0");
		condition.setDrunkDrivingDealTime("");
		condition.setDrunkDrivingFloatingRate("");
		condition.setDrunkDrivingLastYear("");
		condition.setDrunkDrivingNonDealTime("");
		condition.setDrunkDrivingTime("0");
		condition.setDrvOwnerBirthday("");
		condition.setDrvOwnerNme("");
		condition.setDrvOwnerSex("");
		condition.setEndDateLastYear("");
		condition.setExhaust(bill.getVehicleDto().getExhaustMeasure()
				.toString());
		condition.setFormerTax("");
		condition.setFromCde(bill.getFromCde());
		condition.setGroupPurchaseContactNo("");
		condition.setIdType(bill.getCustomerDto().getIdType());
		condition.setLastCompany("");
		condition.setLastPaidYear("");
		condition.setLateFee("");
		condition.setLateFeeChange("");
		condition.setLateFeeValue("");
		condition.setLicenceType("02");
		condition.setLocationCode("");
		condition.setOtherFirstNoProveYear("");
		condition.setOverCommitmentLastYear("");
		condition.setPayChange("");
		condition.setPayChangeLastYear("");
		condition.setPayEvidenceNo("");
		condition.setPayLastYear("0");
		condition.setPayNo("");
		condition.setPayValueCurrent("");
		condition.setPayValueLastYear("");
		condition.setPcCode("");
		condition.setPositionCode("");
		condition.setPosNo("");
		condition.setPower(bill.getVehicleDto().getVehiclePower());
		condition.setQuerySequenceNo("");
		condition.setReduceNo("");
		condition.setReinsFlag("0");
		condition.setRemark("");
		condition.setRenewalPolicyNo("");
		condition.setReturnTaxFlag("");
		condition.setRoadAccidentFloatingRate("");
		condition.setRoadAccidentFloatingRateValue("");
		condition.setSalesmanNo(bill.getOperatorCode());
		condition.setSeatCapacity(bill.getVehicleDto().getVehicleSeat()
				.toString());
		condition.setStartDateLastYear("");
		condition.setSumUpTax("");
		condition.setTaxBeginDateLastYear("");
		condition.setTaxBillingNo("");
		condition.setTaxBillType("");
		condition.setTaxDepartmentName("");
		condition.setTaxPeriod("");
		// 行驶证车辆类型
		condition.setTaxPoCategory(bill.getTaxPoCategory());
		condition.setTaxFreeAmount("");
		condition.setTaxPrintNo("");
		condition.setTaxReduceProp("");
		condition.setTaxReduceRsn("");
		condition.setTaxReduceType("");
		condition.setTaxStandard("");
		condition.setTaxVehicleCategory("K33");
		condition.setTicketType("");
		condition.setTonnage("0");
		condition.setTotalChange("");
		condition.setTotalTaxValue("");
		condition.setTypeMismatchLastYear("");
		condition.setUnitRate("");
		condition.setUnittypeCde("");
		condition.setUntaxedPolicyNo("");
		condition.setUsbkey("");
		condition.setUserType(bill.getCustType());
		condition.setUseStatus("");
		condition.setVoilateRoadSignLastYear("");
		condition.setZip("");
		condition.setAppContact(bill.getCustomerDto().getName());
		condition.setCustomerName("");
		condition.setDrvOwnerBirthday("");
		condition.setDrvOwnerNme("");
		condition.setDrvOwnerSex("");
		// 险别信息
		condition.getRequestCoverageDatas().addAll(coverages);
		// 合作业务来源
		condition.setFromCde(bill.getFromCde());
		condition.setSalesmanNo(bill.getOperatorCode());
		condition.setSource("echannel");
		// 业务来源
		condition.setBusinessType("19008");
		condition.setOperateDate(bill.getOpreated());
		condition.setSignDate(bill.getOpreated());
		// 核心业务 0: GB,1:KB自营, 2: KB下放默认传0
		condition.setKernelFlag("0");
		AgentData agentData = new AgentData();
		agentData.setAgentCode("");
		agentData.setConferCode("");
		agentData.setAgentType("");
		agentData.setAgentCategory("");
		agentData.setCommissionProprortion("0");
		agentData.setAgentProfId("");
		agentData.setAgentStaffNme("");
		agentData.setAgentNme("");
		agentData.setAgentSaleNme("");
		agentData.setAgentCategoryNme("");
		// 客户性质 客户性质 193001 股东 193002 非股东
		agentData.setCustNature("193002");
		agentData.setCusLvl("");
		// 协议序号 代理经纪业务必传
		agentData.setSubCoNo("");
		agentData.setQlftNo("");
		// 合作业务来源
		agentData.setFromCde(bill.getFromCde());
		agentData.setEnterpriseCde("");
		agentData.setEnterpriseNme("");
		agentData.setEnterpriseLvl("");
		agentData.setEnterpriseClass("");
		agentData.setSupportServiceProvider("");
		agentData.setSupportServicePacket("");
		agentData.setAgentStockMrk("");
		agentData.setAgentBankType("");
		agentData.setDutyCde("");
		agentData.setDutyCnm("");
		agentData.setAgentStockType("");
		agentData.setExtProp("");
		agentData.setExtPrm("");
		agentData.setPreventRate("");
		agentData.setTrainRate("");
		condition.setAgentData(agentData);

		request.setCondition(condition);
	}

	/**
	 * 创建保单请求
	 * 
	 * @param request
	 * @param policyAppNo
	 */
	public void buildConfirmVehicleInsuranceApplyRequest(
			ConfirmVehicleInsuranceApplyRequest request, String policyAppNo) {
		RequestBill bill = new RequestBill();
		request.setAuthorityData(authorityData);
		ConfirmVHLApplyCondition condition = new ConfirmVHLApplyCondition();
		condition.setDataSource(bill.DATASOURCE);
		condition.setPolicyAppNo(policyAppNo);
		// 缴税标识 0:不交车船税 1:交车船税
		condition.setTaxFlag("0");
		request.setCondition(condition);
	}
	
	/**
	 * 生成快钱支付请求参数
	 * @param request
	 */
	public void buildThirdBill99PayRequest(ThirdBill99PayRequest request) {
		//1. 先调用第三方保单状态查询接口
		
		request.setAuthorityData(authorityData);
		ThirdBill99PayRequestBase thirdPayBase = new ThirdBill99PayRequestBase();
		//金额
		thirdPayBase.setAmount("");
		//信用卡号
		thirdPayBase.setCardNo("");
		//信用卡有效期(格式MMYY)
		thirdPayBase.setExpiredDate("");
		//卡校验码
		thirdPayBase.setCvv2("");
		//机构编码
		thirdPayBase.setDeptCode("");
		//订单编号 前面第三方保单状态查询返回的订单编号 resp.policyResult.orderCode
		//thirdPayBase.setOrderCode("");
		
		request.setBase(thirdPayBase);
	}

	
	
	private AuthorityData authorityData;
}
